home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / text / manipulation / cv.lha / cv / rexx / ConvertBlock.ced
Encoding:
Text File  |  1993-12-31  |  2.4 KB  |  89 lines

  1. /*
  2. ** ConvertBlock.ced
  3. **
  4. ** $VER: ConvertBlock.ced 1.1 (20.10.93)
  5. **
  6. ** This script is designed to execute from a window within CED to
  7. ** convert the highlighted area (in a block).  It works similar
  8. ** to the built-in functions Rot Marked and Change Case Marked.  You specify
  9. ** an area, then call this function.
  10. **
  11. ** Note:
  12. ** 1. The 'CVT' command must be present in your command path in order for
  13. **       this program to run.
  14. ** 2. This program works with temporary files in T:, so you might want to
  15. **       modify it to store instead on a more appropriate device.
  16. **
  17. ** This script requires CygnusEd Professional v3.5 (or later) to run.
  18. **
  19. ** It is part of the CV package and very loosely based on SortBlock.ced which is
  20. **       Copyright © 1990-1993 ASDG, Incorporated  All Rights Reserved
  21. **
  22. */
  23.  
  24. ADDRESS "rexx_ced"
  25. OPTIONS RESULTS
  26.  
  27. TempOriginalBlock = "T:TempOriginalBlock"
  28. TempConvertedBlock = "T:TempConvertedBlock"
  29. ConversionScript = "Empty"
  30. CVScriptsPath= ""
  31.  
  32. IF OPEN(fp,"ENV:CVSCRIPTS",'R') THEN DO
  33.   done= EOF(fp);
  34.   DO UNTIL done
  35.     c= READCH(fp)
  36.     done = (c = ',') | (c = ';') | EOF(fp)
  37.     IF ~done THEN CVScriptsPath= CVScriptsPath || c
  38.   END
  39.   dummy= CLOSE(fp)
  40.   IF (CVScriptsPath = "") | (CVScriptsPath = ".") THEN DO
  41.     STATUS CURRENTDIR
  42.     CVScriptsPath= RESULT
  43.   END
  44.   IF (CVScriptsPath ~= "") THEN DO
  45.     IF (RIGHT(CVScriptsPath,1) ~= '/') & (RIGHT(CVScriptsPath,1) ~= ':') THEN
  46.       CVScriptsPath = CVScriptsPath || '/'
  47.   END
  48.   ELSE DO
  49.     OKAY1 "Can't locate CV scripts. -- Sorry."
  50.     EXIT 0
  51.   END
  52. END
  53. ELSE DO
  54.   OKAY1 "Can't find environment variable CVSCRIPTS"
  55.   EXIT 0
  56. END
  57.  
  58. CUT
  59. IF (RESULT ~= 0) THEN DO
  60.   GETFILENAME CVScriptsPath '"Convert Block Using ..."'
  61.   ConversionScript= RESULT
  62.   IF(ConversionScript = "") | (ConversionScript = "RESULT") THEN DO
  63.     PASTE
  64.     EXIT 0
  65.   END
  66.   SAVE CLIP AS TempOriginalBlock
  67.  
  68.   From = '"' || TempOriginalBlock  || '"'
  69.   To   = '-o "' || TempConvertedBlock || '"'
  70.  
  71.   ADDRESS COMMAND 'CVT -s -f "' || ConversionScript || '"' From To
  72.  
  73.   ADDRESS "rexx_ced" INCLUDE FILE TempConvertedBlock
  74.   /*
  75.   ** This STATUS command will ensure that CED finishes loading the
  76.   ** sorted file before ARexx sends off the command to delete the file.
  77.   */
  78.   STATUS RESTNAME
  79.  
  80.   ADDRESS COMMAND "Delete > NIL:" TempOriginalBlock
  81.   ADDRESS COMMAND "Delete > NIL:" TempConvertedBlock
  82. END
  83. ELSE DO
  84.   CEDTOFRONT
  85.   OKAY1 "Can't convert block.  No area was marked."
  86. END
  87.  
  88. EXIT 0
  89.